<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"></div>

  <template id="my-app">
    <!-- 1.mustache的基本使用 -->
    <h2>{{ message }}</h2>
    <!-- 2.表达式 -->
    <h3>{{ counter * 10 }}</h3>
    <h3>{{ message.split(" ").reverse().join(" ") }}</h3>
    <!-- 3.调用函数 -->
    <!-- 可以使用computed(计算属性) -->
    <h4>{{ getReverseMessage() }}</h4>
    <!-- 4.三元运算符 -->
    <h5>{{ isShow ? '哈哈哈' : '嘿嘿嘿' }}</h5>
    <button @click="isShow = !isShow">切换</button>
  </template>

  <script src="../js/vue.js"></script>

  <script>
    const App = {
      template: "#my-app",
      data() {
        return {
          message: "Hello World",
          counter: 100,
          isShow: true
        }
      },
      methods: {
        getReverseMessage() {
          return this.message.split(" ").reverse().join(" ");
        }
      }
    }

    Vue.createApp(App).mount("#app");
  </script>
</body>

</html>